//package top.kuangcp.graduate.config;
//
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
//
///**
// * Created by https://github.com/kuangcp
// *
// * @author kuangcp
// * @date 18-4-25  下午6:51
// */
//@ControllerAdvice(basePackageClasses = AcmeController.class)
//public class AcmeControllerAdvice extends ResponseEntityExceptionHandler {
//
//    @ExceptionHandler(YourException.class)
//    @ResponseBody
//    ResponseEntity<?> handleControllerException(HttpServletRequest request, Throwable ex) {
//        HttpStatus status = getStatus(request);
//        return new ResponseEntity<>(new CustomErrorType(status.value(), ex.getMessage()), status);
//    }
//
//    private HttpStatus getStatus(HttpServletRequest request) {
//        Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
//        if (statusCode == null) {
//            return HttpStatus.INTERNAL_SERVER_ERROR;
//        }
//        return HttpStatus.valueOf(statusCode);
//    }
//
//}
